<template>
  <div class="home">
    <!-- <Quill v-model="content"></Quill> -->
    <v-md-editor
      v-model="value"
      height="400px"
      :disabled-menus="[]"
      @change="change"
      @copy-code-success="handleCopyCodeSuccess"
      @upload-image="handleUploadImage"
    ></v-md-editor>

    <div style="margin-top: 100px"></div>
    <v-md-preview-html
      :html="hmtl"
      preview-class="vuepress-markdown-body"
      @copy-code-success="handleCopyCodeSuccess"
    ></v-md-preview-html>
  </div>
</template>

<script>
import Quill from "@/components/quill";
export default {
  name: "Home",
  components: { Quill },
  data() {
    return {
      content: "asdasd",
      value: "",
      hmtl: "",
    };
  },
  mounted() {},
  methods: {
    change(text, html) {
      this.hmtl = html;
    },
    handleCopyCodeSuccess(code) {
      const clipboard = navigator.clipboard;
      if (clipboard) navigator.clipboard.writeText(code);
    },
    handleUploadImage(event, insertImage, files) {
      // 拿到 files 之后上传到文件服务器，然后向编辑框中插入对应的内容
      console.log(files);

      // 此处只做示例
      insertImage({
        url: "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1269952892,3525182336&fm=26&gp=0.jpg",
        desc: "七龙珠",
        // width: 'auto',
        // height: 'auto',
      });
    },
  },
  computed: {},
  watch: {},
};
</script>

<style lang="scss" scoped>
.home {
  padding: 50px;
  .code {
    width: 1000px;
    height: 500px;
    margin-top: 50px;
    background-color: #eee;
    padding: 10px;
    box-sizing: border-box;
  }
}
</style>
